<template>
    <div>
      <div class="content">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="菜单名称" class="form-header">
            <el-input
              v-model="formInline.menuName"
              placeholder="菜单名称"
            ></el-input>
          </el-form-item>
          <!-- <el-form-item label="广告图片" class="form-header">
            <ImageUpload :limit="1" :fileLists="fileList" @handleUploadSuccess="handleUploadSuccess">
            </ImageUpload>
          </el-form-item> -->
          <el-form-item label="菜单类型" class="form-header">
            <el-select v-model="formInline.menuType" placeholder="请选择">
                    <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                    </el-option>
                </el-select>
          </el-form-item>
          <el-form-item label="图标地址" class="form-header">
            <el-input
              v-model="formInline.menuIcon"
              placeholder="图标地址"
            ></el-input>
          </el-form-item>
          <el-form-item label="功能说明" class="form-header">
            <el-input
              v-model="formInline.menuCenter"
              placeholder="功能说明"
            ></el-input>
          </el-form-item>
          <el-form-item label="消费：元" class="form-header">
            <el-input
              v-model="formInline.consumption"
              placeholder="消费：元"
            ></el-input>
          </el-form-item>
          <el-form-item label="日预算：元" class="form-header">
            <el-input
              v-model="formInline.dayBudget"
              placeholder="日预算：元"
            ></el-input>
          </el-form-item>
          <el-form-item label="跳转链接" class="form-header">
            <el-input
              v-model="formInline.menuLink"
              placeholder="跳转链接"
            ></el-input>
          </el-form-item>
          <el-form-item label="排序" class="form-header">
            <el-input
              v-model="formInline.sort"
              placeholder="排序"
            ></el-input>
          </el-form-item>
          <el-form-item label="申请状态" class="form-header">
            <el-select v-model="formInline.menuFlag" placeholder="请选择">
                    <el-option
                    v-for="item in options2"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                    </el-option>
                </el-select>
          </el-form-item>
        </el-form>
      </div>
      <div class="queding">
        <el-button type="primary" @click="handleSubmit">确定</el-button>
        <el-button type="primary" plain @click="$emit('banfan')"
          >取消</el-button
        >
      </div>
    </div>
  </template>
  <script>
  import { listAllUser } from "@/api/caiwu/zhgl";
  import { add, edit } from "@/api/gongneng/index";
  import { mapState } from "vuex";
  export default {
    name: "zhanghugai",
    data() {
      return {
        options2:[
        {
          value: '进入',
          label: '进入'
        }, {
          value: '申请开通',
          label: '申请开通'
        }, {
          value: '暂未开通',
          label: '暂未开通'
        }
        ],
        options: [{
          value: '推广服务',
          label: '推广服务'
        }, {
          value: '营销服务',
          label: '营销服务'
        }],
        formInline: {
            menuId:"",
            menuName:"",
            menuType:"",
            menuIcon:"",
            menuCenter:"",
            consumption:"",
            dayBudget:"",
            menuFlag:"",
            menuLink:"",
            sort:""
        },
        fileSize: 5,
        fileType: ["png", "jpg", "jpeg"],
        // dialogVisible: false,
        // disabled: false,
        fileList: [],
        userList: [],
        dialogImageUrl: "",
      };
    },
    computed: {
     
    },
    props: {
      // 编辑数据
      objData: {
        type: Object,
        default: () => {},
      },
    
    },
    mounted() {
      if(this.objData){
        console.log('ddd',this.objData)
        this.formInline=this.objData
      }
    },
    methods: {
    
   
      // TODO: 新增、编辑提交
      handleSubmit() {
        if(this.formInline.menuId == undefined){
          console.log('应该走这里吧')
            add(this.formInline).then((res)=>{
            if(res.code ==200){
                this.$message({
                message: '恭喜你，这是一条成功消息',
                type: 'success'
                });
              this.$emit('banfan')
            }
        })
        }else{
            edit(this.formInline).then((res)=>{
            if(res.code ==200){
                this.$message({
                message: '恭喜你，这是一条成功消息',
                type: 'success'
                });
              this.$emit('banfan')
            }
        })
        }
       
      },
      // 重置表单
    
    
    },
  };
  </script>
  <style scoped>
  .queding {
    padding-bottom: 28px;
    text-align: center;
    display: flex;
    justify-content: space-around;
    width: 34%;
    margin: 0 auto;
  }
  .form-header {
    width: 492px;
    border: none;
  }
  .slect {
    width: 204px;
  }
  .content {
    width: 90%;
    margin: 0 auto;
    margin-top: 30px;
  }
  </style>
  